<script type="text/javascript">
function loadFileNumbers(){
	$('.folder_id').each(function( index ) {
		var id= $(this).val();
		${remoteFunction(
				action:'files_number',
				controller:'docType',
				update: [success: 'number_files_\'+id+\''],
				params:'\'id=\' +id ')}
		});
}
$(document).ready(function(){
	loadFileNumbers();
	});
</script>

<div class="tree smart-form ">
	<ul>
		<li><span title="Espandi"><i class="fa fa-lg fa-folder-open "></i>Upload</span>
			<g:if test="${folders}">
				<ul >
				<g:each in="${folders }" var="folder">
				
					<li data-toggle="tooltip" title="Cliccca per vedere i file nella cartella">
						<span title="Espandi">
						<input class="folder_id" type="hidden" value="${folder.id}">
							<i id="${folder.id}it" class="fa fa-lg fa-folder-o "></i>
								${folder.documentType}&nbsp;&nbsp;
								<span class="badge bg-color-blue"><b id="number_files_${folder.id}">0</b> files</span>
							&nbsp;&nbsp;<button type="button" class="btn btn-primary btn-sm" id="add_role" onclick="show_files(${folder.id},'date');"><i class="fa fa-lg fa-folder-open-o"></i></button>
							<sec:ifAnyGranted roles="ROLE_ADMIN,ROLE_AMM">
							&nbsp;&nbsp;<button type="button" class="btn btn-danger btn-sm" id="add_role" onclick="folderCancelAlert(${folder.id});"><i class="fa fa-lg fa-trash-o"></i></button>
							</sec:ifAnyGranted>	
						</span>
<%--						<ul>--%>
<%--							<li onclick="" data-toggle="tooltip" title="Cliccca per vedere i file nella cartella">--%>
<%--								<span><i  class="fa "></i> Apri</span> --%>
<%--							</li>--%>
<%--							--%>
<%--								<li onclick="folderCancelAlert(${folder.id})" data-toggle="tooltip" title="Cancella Cartella">--%>
<%--									<span><i class="fa fa-trash-o"></i></span>--%>
<%--								</li>--%>
<%--							--%>
<%--						</ul>--%>
						
					</li>
				
				</g:each>
				</ul>
				</g:if>
			</li>
		
	</ul>
</div>